﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedGenomics.Domain
{
    public static class MethodArgumentValidator
    {
        /// <summary>
        /// Validates that a value is valid for a particular enum type
        /// </summary>
        /// <typeparam name="T">The enum type to validate against</typeparam>
        /// <param name="value">The value to validate</param>
        public static void ValidateEnum<T>(T value) where T : struct
        {
            Type enumType = typeof(T);

            if (!enumType.IsEnum || !Enum.IsDefined(enumType, value))
                throw new ArgumentException(String.Format("{0} is not a valid value for {1}", value, enumType.Name));
        }
    }
}
